<template >
  <div >
    <el-container>
      <el-aside width="200px" v-show="showMenu">
        <el-menu
          default-active="1"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          background-color="4cbefb"
          text-color="#fff"
          active-text-color="#f7f030"
          :default-openeds="['0','1', '2', '2-x', '2-y']"
        >
          <el-sub-menu index="0"> 
              <template #title>
                书籍管理
              </template>
              <el-menu-item index="1" @click="topage('/writer/individual')">个人管理</el-menu-item>
              <el-sub-menu index="2"> 
                <template #title>
                  书籍管理
                </template>
                <el-menu-item index="2-x" @click="topage('/writer/booktype')">书籍管理</el-menu-item>
                <!-- <el-menu-item index="2-y" @click="topage('/writer/bookpart')">书籍内容</el-menu-item> -->
              </el-sub-menu>
          </el-sub-menu>

         </el-menu>
         
      </el-aside>

      <el-container>

        <el-header>
          {{ time }}
          <el-row>
            <el-col :span="1">
             <el-icon @click="hideOrShow"><Grid /></el-icon>
            </el-col>

            <el-col :span="17">
              
            </el-col>

            <el-col :span="6">
             <el-icon><User /></el-icon> {{username}}
            </el-col>
          </el-row>
        </el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
       
      </el-container>
    </el-container>
  </div>
</template>

<script setup>
import { ref,onMounted } from 'vue';
// import { ElContainer, ElAside, ElMenu, ElMenuItem, ElSubMenu, ElIcon, ElHeader, ElMain, ElFooter } from 'element-plus';
// import { Menu as IconMenu, Location, Document, Setting } from '@element-plus/icons-vue';
import { useRouter,useRoute } from 'vue-router';
const route = useRoute();
const router = useRouter();
const username =ref('')
const userid =ref('')
const showMenu = ref(true);
const time=ref(new Date().toLocaleString())

onMounted(()=>{
  username.value = route.query.username
  userid.value = route.query.userid
   setInterval(() => {
    time.value = new Date().toLocaleString();
  }, 1000);
})
const hideOrShow=()=>{ 
  showMenu.value = !showMenu.value

}
const handleOpen = (key, keyPath) => {
  console.log(key, keyPath);
};

const handleClose = (key, keyPath) => {
  console.log(key, keyPath);
};
//菜单页面跳转
const topage=(path)=>{
   const currentQuery = route.query;
  router.push({ path: path ,
    query:{
      ...currentQuery

    
  }
   })
}
</script>

<style scoped>
.home-container {
  height: 100vh;
  width: 100vw;
  margin: 0px;
  padding: 0px;
}

.el-container {
    height: 100vh;
    width: 100vw;
    margin: 0px;
    padding: 0px;
}

.el-aside {
  background-color: #4c8dce;
  color: #f7f030;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}
</style>



